package com.hznu.jspFinal.service;

import com.hznu.jspFinal.dao.CourseMapper;
import com.hznu.jspFinal.entity.Course;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * author:wp
 * time : 2018/06/07
 */
@Service
public class CourseServiceImpl implements CourseService {

    @Autowired
    private CourseMapper courseMapper;

    @Override
    public int addOne(Course course) {
        return courseMapper.insertSelective(course);
    }

    @Override
    public int update(Course course) {
        return courseMapper.updateByPrimaryKeySelective(course);
    }

    @Override
    public int delete(Integer id) {
        return courseMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Course findByName(String name) {
        return courseMapper.selectByName(name);
    }

    @Override
    public Course findById(Integer id) {
        return courseMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Course> findByCreatorid(Integer creatorid) {
        return courseMapper.selectByCreatorid(creatorid);
    }

}
